#include "hl_node.h"
#ifndef HL_PARSERESULT_H
#define HL_PARSERESULT_H
class ParseResult {
public:
	Error* error;
	Node* node;
	int last_registered_advance_count = 0;
	int advance_count = 0;
	int to_reverse_count = 0;
	ParseResult() {
	};
	void register_advancement() {
		last_registered_advance_count = 1;
		advance_count++;
	}
	ParseResult* registe(ParseResult* res) {
		last_registered_advance_count = res->advance_count;
		advance_count += res->advance_count;
		if (res->error)
		{
			this->error = res->error;
		}
		res->node;
		return res;
	}
	ParseResult* try_register(ParseResult* res) {
		if (res->error)
		{
			to_reverse_count == res->advance_count;
			return NULL;
		}
		return registe(res);
	}
	ParseResult* success(Node* node) {
		this->node = node;
		return this;
	}
	ParseResult* failure(Error* error) {
		if (not error or last_registered_advance_count==0)
		{
			this->error = error;
		}
		return this;
	}
};
#endif // HL_PARSERESULT_H


